package nil.ed.simulator.request.biz.qq.activity;

import nil.ed.simulator.request.client.activity.AbstractHttpActivity;
import nil.ed.simulator.request.enums.ActivityGroup;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;

/**
 * App Index 活动.
 * @author lidelin.
 */
public class Seq002AppIndexActivity extends AbstractHttpActivity {

        private static final String APP_INDEX_URL = "https://aq.qq.com/cn2/manage/mbtoken/app_index";

    @Override
    protected HttpUriRequest getRequest(Map<String, Object> attrMap) {
        return new HttpGet(APP_INDEX_URL);
    }

    @Override
    protected boolean doFinalProcess(HttpResponse response, Map<String, Object> customAttrMap) {
        try {
            customAttrMap.put("appid", "2001601");
            customAttrMap.put("appIndexSiteUrlEncoded", URLEncoder.encode(APP_INDEX_URL, StandardCharsets.UTF_8.name()));
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public ActivityGroup getGroup() {
        return ActivityGroup.QQ_LOGIN;
    }

    @Override
    public int getSort() {
        return 1;
    }
}
